package be.fomp.jeve.application.data;

import java.util.Date;

import org.jdom.Document;
import org.jdom.Element;

import be.fomp.jeve.application.util.DateParser;

public abstract class AbstractResultImpl implements AbstractResult {
	private int version;
	private Date currentTime;
	private Date cachedUntil;
	
	protected AbstractResultImpl(Document result) {
		
		Element api = result.getRootElement();
		version = Integer.parseInt(api.getAttributeValue("version"));

		String date = api.getChild("currentTime").getText();
		currentTime = DateParser.parseDate(date);
		
		date = api.getChild("cachedUntil").getText();
		cachedUntil = DateParser.parseDate(date);
	}
	
	public final int getVersion() {
		return version;
	}
	
	public final Date getCurrentTime() {
		return currentTime;
	}
	
	public final Date getCachedUntil() {
		return cachedUntil;
	}
}
